<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Calendar" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/8/23
  Time: 14:45
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>新建销售机会</title>

    <link rel="shortcut icon" href="<c:url value="/images/favicon.ico"/>" type="image/x-icon"/>
    <script src="<c:url value="/js/jquery-1.9.1.min.js"/>"></script>
    <script src="<c:url value="/layui/layui.js"/>"></script>
    <link rel="stylesheet" type="text/css" href="<c:url value="/layui/css/layui.css"/>">

    <script src="<c:url value="/js/my/commons.js"/>"></script>
    <style>
        .container {
            width: 1700px;
            margin: -80px auto;
        }
        table{
            width: 100%;
        }
    </style>

</head>
<body class="container">

<form class="layui-form layui-form-pane" style="margin-left: 450px" id="acsalesForm">

    <div class="layui-form-item" style="margin-top: 120px;">
        <%--    编号    --%>
        <div class="layui-inline">
            <label class="layui-form-label">编号：</label>
            <div class="layui-input-inline">
                <input id="id" name="id" lay-verify="required" value="1"
                       type="text" autocomplete="off" class="layui-input"  placeholder="1" readonly="readonly">
            </div>
        </div>
        <%--    机会来源    --%>
        <div class="layui-inline" style="margin-left: 100px">
            <label class="layui-form-label">机会来源：</label>
            <div class="layui-input-inline">
                <input id="source" name="source" lay-verify="required"
                       type="text" autocomplete="off" class="layui-input" placeholder="请输入机会来源">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <%--     客户名称   --%>
        <div class="layui-inline">
            <label class="layui-form-label">客户名称：</label>
            <div class="layui-input-inline">
                <input id="customerName" name="customerName" lay-verify="required"
                       type="text" autocomplete="off" class="layui-input" placeholder="请输入客户名称">
            </div>
        </div>
        <%--     成功几率   --%>
        <div class="layui-inline" style="margin-left: 100px">
            <label class="layui-form-label">成功几率：</label>
            <div class="layui-input-inline">
                <input id="success" name="success" lay-verify="success"
                       type="text" autocomplete="off" class="layui-input" placeholder="请输入成功几率">
            </div>
        </div>
    </div>

    <%--    概要   --%>
    <div class="layui-form-item">
        <label class="layui-form-label">概要：</label>
        <div class="layui-input-block" style="width: 615px">
            <input id="general" name="general" lay-verify="required"
                   type="text" autocomplete="off" placeholder="请输入概要" class="layui-input">
        </div>
    </div>

    <%--    <div class="layui-form-item">--%>
    <%--        &lt;%&ndash;    状态    &ndash;%&gt;--%>
    <%--        <div class="layui-inline">--%>
    <%--            <label class="layui-form-label">状态：</label>--%>
    <%--            <div class="layui-input-inline">--%>
    <%--                <input id="status" name="status" lay-verify="required"--%>
    <%--                       type="text" autocomplete="off" class="layui-input" placeholder="从数据库导入">--%>
    <%--            </div>--%>
    <%--        </div>--%>
    <%--    </div>--%>

    <div class="layui-form-item">
        <%--    联系人    --%>
        <div class="layui-inline">
            <label class="layui-form-label">联系人：</label>
            <div class="layui-input-inline">
                <input id="name" name="name" lay-verify="required"
                       type="text" autocomplete="off" class="layui-input" placeholder="请输入联系人">
            </div>
        </div>
        <%--    联系电话    --%>
        <div class="layui-inline" style="margin-left: 100px">
            <label class="layui-form-label">联系电话：</label>
            <div class="layui-input-inline">
                <input id="mobile_phone" name="mobile_phone" lay-verify="mobile_phone"
                       type="text" autocomplete="off" class="layui-input" placeholder="请输入联系人电话">
            </div>
        </div>
    </div>

    <%--    机会描述   --%>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label" style="width: 723px">机会描述：</label>
        <div class="layui-input-block" style="width: 723px">
            <textarea id="description" name="description"
                      lay-verify="required" placeholder="请输入机会描述" class="layui-textarea"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <%--     创建人   --%>
        <div class="layui-inline">
            <label class="layui-form-label">创建人：</label>
            <div class="layui-input-inline">
                <input id="creater" name="creater" lay-verify="required" value="${sessionScope.user.realName}"
                       type="text" autocomplete="off" class="layui-input" placeholder="请输入创建人" readonly="readonly">
            </div>
        </div>
        <%--     创建时间   --%>
        <div class="layui-inline" style="margin-left: 100px">
            <label class="layui-form-label">创建时间：</label>
            <div class="layui-input-inline">
                <input id="create_date" name="create_date" lay-verify="required"
                       value="<%=new SimpleDateFormat("yyyy-MM-dd  HH:mm:ss").format(Calendar.getInstance().getTime())%>"
                       type="text" placeholder="请输入创建时间" autocomplete="off" class="layui-input" readonly="readonly">
            </div>
        </div>
    </div>

    <%--    <div class="layui-form-item">--%>
    <%--        &lt;%&ndash;     指派人   &ndash;%&gt;--%>
    <%--        <div class="layui-inline">--%>
    <%--            <label class="layui-form-label">指派人</label>--%>
    <%--            <div class="layui-input-inline">--%>
    <%--                <select id="zpr" name="zpr" lay-verify="required" lay-search="">--%>
    <%--                    <option value="">请选择指派人</option>--%>
    <%--                    <option value="1">layer</option>--%>
    <%--                    <option value="2">form</option>--%>
    <%--                    <option value="3">layim</option>--%>
    <%--                    <option value="4">element</option>--%>
    <%--                    <option value="5">laytpl</option>--%>
    <%--                    <option value="6">upload</option>--%>
    <%--                    <option value="7">laydate</option>--%>
    <%--                    <option value="8">laypage</option>--%>
    <%--                    <option value="9">flow</option>--%>
    <%--                    <option value="10">util</option>--%>
    <%--                    <option value="11">code</option>--%>
    <%--                    <option value="12">tree</option>--%>
    <%--                    <option value="13">layedit</option>--%>
    <%--                    <option value="14">nav</option>--%>
    <%--                    <option value="15">tab</option>--%>
    <%--                    <option value="16">table</option>--%>
    <%--                    <option value="17">select</option>--%>
    <%--                    <option value="18">checkbox</option>--%>
    <%--                    <option value="19">switch</option>--%>
    <%--                    <option value="20">radio</option>--%>
    <%--                </select>--%>
    <%--            </div>--%>
    <%--        </div>--%>
    <%--        &lt;%&ndash;     指派時間   &ndash;%&gt;--%>
    <%--        <div class="layui-inline" style="margin-left: 100px">--%>
    <%--            <label class="layui-form-label">指派时间：</label>--%>
    <%--            <div class="layui-input-inline">--%>
    <%--                <input id="zp_time" name="zp_time" lay-verify="required"--%>
    <%--                       type="text" placeholder="从数据库导入" autocomplete="off" class="layui-input" readonly="readonly">--%>
    <%--            </div>--%>
    <%--        </div>--%>
    <%--    </div>--%>

    <div class="layui-form-item" style="margin-left: 550px">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1">保存</button>
        </div>
    </div>

</form>

<script>
    layui.use(['form','table','layer','laydate','layedit'], function(){
        var $ = layui.$
            ,table = layui.table
            ,form = layui.form
            ,layer = layui.layer
            ,laydate = layui.laydate
            ,layedit = layui.layedit;

        form.verify({

            success: [
                /^(?:[1-9]?\d|100)$/
                ,'概率必须是数字，且不能超过100'
            ]
            , mobile_phone: [
                /^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/
                , '手机号码不对，请重新输入'
            ]

        });

        //监听提交
        form.on('submit(demo1)', function(data){
            // layer.alert(JSON.stringify(data.field));
            data=JSON.stringify(data.field);
            $.ajax({
                url: '<c:url value="/add.do"/>',
                type:'post',
                dataType:'text',
                data:{
                    jsonString : data
                },
                success:function(msg){
                    if (msg=="cz"){
                        layer.confirm('客户名称已存在，请重新输入', {icon: 2, title:'提示'}, function(index){
                            //do something
                            $("#customerName").val("");
                            layer.close(index);
                        });
                    }
                    else if (msg=="success"){
                        layer.confirm('添加成功', {icon: 1, title:'提示'}, function(index){
                            //do something

                            layer.close(index);
                            window.parent.location.reload();
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                        });
                    }else{
                        layer.confirm('添加失败', {icon: 2, title:'提示'}, function(index){
                            //do something

                            layer.close(index);
                        });
                    }
                }
            })
            return false;
        });

    });




</script>


</body>
</html>
